﻿using System;
using System.Data;
using System.Text;

using System.Data.OracleClient;
using System.Collections;

using DQYT.HTDZ.Common;
using Maticsoft.DBUtility;
using DQYT.HTDZ.Model;

namespace DQYT.HTDZ.DAL
{
    /// <summary>
    /// 数据访问类:SKGYSJB
    /// </summary>
    public partial class SkgysjbDAL
    {
        public SkgysjbDAL()
        { }
        #region  Method

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(decimal ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from SKGYSJB");
            strSql.Append(" where ID=:ID ");
            OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,10)			};
            parameters[0].Value = ID;

            return DbHelperOra.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(SkgysjbModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into SKGYSJB(");
            strSql.Append("ID,LRRQ,JH,JB,CB,WJFS,SGLX,SKQX,SKDX,CSFS,CYSXH,YGLX,YGGG,SJYGWGSD,TSSGLX,SYYL,TGDJG,ZLHSD,SKMD,XW,FY,WJYMC,WJYMD,WJYYL,SKJD1,SKJD2,SKHD,YSK,JSDW,LRR,SHR,BZ,BKCS,YL,BZ1,OK,TRANS,CSRQ,XH,SKDX1,YSK1,SKMD1,YGLX1,SJYGWGSD1,YGGG1,BKGS,ZJYLX,SKQX2,SKHD2,QK,KB,DATAMIGRATION_ID,DCYL,TSJ,YCZBSD,XCS,TGTZBXG,SKBJ,SGDW,cj)");
            strSql.Append(" values (");
            strSql.Append(":ID,:LRRQ,:JH,:JB,:CB,:WJFS,:SGLX,:SKQX,:SKDX,:CSFS,:CYSXH,:YGLX,:YGGG,:SJYGWGSD,:TSSGLX,:SYYL,:TGDJG,:ZLHSD,:SKMD,:XW,:FY,:WJYMC,:WJYMD,:WJYYL,:SKJD1,:SKJD2,:SKHD,:YSK,:JSDW,:LRR,:SHR,:BZ,:BKCS,:YL,:BZ1,:OK,:TRANS,:CSRQ,:XH,:SKDX1,:YSK1,:SKMD1,:YGLX1,:SJYGWGSD1,:YGGG1,:BKGS,:ZJYLX,:SKQX2,:SKHD2,:QK,:KB,:DATAMIGRATION_ID,:DCYL,:TSJ,:YCZBSD,:XCS,:TGTZBXG,:SKBJ,:SGDW,:cj)");
            OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,10),
					new OracleParameter(":LRRQ", OracleType.DateTime),
					new OracleParameter(":JH", OracleType.VarChar,32),
					new OracleParameter(":JB", OracleType.VarChar,10),
					new OracleParameter(":CB", OracleType.VarChar,20),
					new OracleParameter(":WJFS", OracleType.VarChar,20),
					new OracleParameter(":SGLX", OracleType.VarChar,20),
					new OracleParameter(":SKQX", OracleType.VarChar,20),
					new OracleParameter(":SKDX", OracleType.VarChar,20),
					new OracleParameter(":CSFS", OracleType.VarChar,20),
					new OracleParameter(":CYSXH", OracleType.VarChar,200),
					new OracleParameter(":YGLX", OracleType.VarChar,200),
					new OracleParameter(":YGGG", OracleType.VarChar,200),
					new OracleParameter(":SJYGWGSD", OracleType.Number,6),
					new OracleParameter(":TSSGLX", OracleType.VarChar,100),
					new OracleParameter(":SYYL", OracleType.VarChar,10),
					new OracleParameter(":TGDJG", OracleType.Number,5),
					new OracleParameter(":ZLHSD", OracleType.Number,7),
					new OracleParameter(":SKMD", OracleType.Number,4),
					new OracleParameter(":XW", OracleType.Number,5),
					new OracleParameter(":FY", OracleType.VarChar,14),
					new OracleParameter(":WJYMC", OracleType.VarChar,20),
					new OracleParameter(":WJYMD", OracleType.Number,5),
					new OracleParameter(":WJYYL", OracleType.Number,3),
					new OracleParameter(":SKJD1", OracleType.Number,7),
					new OracleParameter(":SKJD2", OracleType.Number,7),
					new OracleParameter(":SKHD", OracleType.Number,7),
					new OracleParameter(":YSK", OracleType.Number,4),
					new OracleParameter(":JSDW", OracleType.VarChar,30),
					new OracleParameter(":LRR", OracleType.VarChar,20),
					new OracleParameter(":SHR", OracleType.VarChar,20),
					new OracleParameter(":BZ", OracleType.VarChar ,4000),//OracleType.LongVarChar
					new OracleParameter(":BKCS", OracleType.Number,1),
					new OracleParameter(":YL", OracleType.Number,4),
					new OracleParameter(":BZ1", OracleType.VarChar,100),
					new OracleParameter(":OK", OracleType.Number,1),
					new OracleParameter(":TRANS", OracleType.Number,1),
					new OracleParameter(":CSRQ", OracleType.DateTime),
					new OracleParameter(":XH", OracleType.Number,2),
					new OracleParameter(":SKDX1", OracleType.VarChar,20),
					new OracleParameter(":YSK1", OracleType.Number,4),
					new OracleParameter(":SKMD1", OracleType.Number,4),
					new OracleParameter(":YGLX1", OracleType.VarChar,200),
					new OracleParameter(":SJYGWGSD1", OracleType.Number,6),
					new OracleParameter(":YGGG1", OracleType.VarChar,200),
					new OracleParameter(":BKGS", OracleType.VarChar,16),
					new OracleParameter(":ZJYLX", OracleType.VarChar,8),
					new OracleParameter(":SKQX2", OracleType.VarChar,20),
					new OracleParameter(":SKHD2", OracleType.Number,7),
					new OracleParameter(":QK", OracleType.VarChar,20),
					new OracleParameter(":KB", OracleType.VarChar,10),
					new OracleParameter(":DATAMIGRATION_ID", OracleType.Number,4),
					new OracleParameter(":DCYL", OracleType.Number,6),
					new OracleParameter(":TSJ", OracleType.VarChar,20),
					new OracleParameter(":YCZBSD", OracleType.Number,8),
					new OracleParameter(":XCS", OracleType.Number,2),
					new OracleParameter(":TGTZBXG", OracleType.Number,8),
					new OracleParameter(":SKBJ", OracleType.VarChar,20),
					new OracleParameter(":SGDW", OracleType.VarChar,10),
                    new OracleParameter(":cj", OracleType.VarChar,50)};
            parameters[0].Value = GetNextID(); //model.ID;
            parameters[1].Value = model.LRRQ;
            parameters[2].Value = model.JH;
            parameters[3].Value = model.JB;
            parameters[4].Value = model.CB;
            parameters[5].Value = model.WJFS;
            parameters[6].Value = model.SGLX;
            parameters[7].Value = model.SKQX;
            parameters[8].Value = model.SKDX;
            parameters[9].Value = model.CSFS;
            parameters[10].Value = model.CYSXH;
            parameters[11].Value = model.YGLX;
            parameters[12].Value = model.YGGG;
            parameters[13].Value = model.SJYGWGSD;
            parameters[14].Value = model.TSSGLX;
            parameters[15].Value = model.SYYL;
            parameters[16].Value = model.TGDJG;
            parameters[17].Value = model.ZLHSD;
            parameters[18].Value = model.SKMD;
            parameters[19].Value = model.XW;
            parameters[20].Value = model.FY;
            parameters[21].Value = model.WJYMC;
            parameters[22].Value = model.WJYMD;
            parameters[23].Value = model.WJYYL;
            parameters[24].Value = model.SKJD1;
            parameters[25].Value = model.SKJD2;
            parameters[26].Value = model.SKHD;
            parameters[27].Value = model.YSK;
            parameters[28].Value = model.JSDW;
            parameters[29].Value = model.LRR;
            parameters[30].Value = model.SHR;
            parameters[31].Value = model.BZ;
            parameters[32].Value = model.BKCS;
            parameters[33].Value = model.YL;
            parameters[34].Value = model.BZ1;
            parameters[35].Value = model.OK;
            parameters[36].Value = model.TRANS;
            parameters[37].Value = model.CSRQ;
            parameters[38].Value = model.XH;
            parameters[39].Value = model.SKDX1;
            parameters[40].Value = model.YSK1;
            parameters[41].Value = model.SKMD1;
            parameters[42].Value = model.YGLX1;
            parameters[43].Value = model.SJYGWGSD1;
            parameters[44].Value = model.YGGG1;
            parameters[45].Value = model.BKGS;
            parameters[46].Value = model.ZJYLX;
            parameters[47].Value = model.SKQX2;
            parameters[48].Value = model.SKHD2;
            parameters[49].Value = model.QK;
            parameters[50].Value = model.KB;
            parameters[51].Value = GetNextID("DATAMIGRATION_ID"); // model.DATAMIGRATION_ID;
            parameters[52].Value = model.DCYL;
            parameters[53].Value = model.TSJ;
            parameters[54].Value = model.YCZBSD;
            parameters[55].Value = model.XCS;
            parameters[56].Value = model.TGTZBXG;
            parameters[57].Value = model.SKBJ;
            parameters[58].Value = model.SGDW;
            parameters[59].Value = model.cj;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SkgysjbModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update SKGYSJB set ");
            strSql.Append("ID=:ID,");
            strSql.Append("LRRQ=:LRRQ,");
            strSql.Append("JH=:JH,");
            strSql.Append("JB=:JB,");
            strSql.Append("CB=:CB,");
            strSql.Append("WJFS=:WJFS,");
            strSql.Append("SGLX=:SGLX,");
            strSql.Append("SKQX=:SKQX,");
            strSql.Append("SKDX=:SKDX,");
            strSql.Append("CSFS=:CSFS,");
            strSql.Append("CYSXH=:CYSXH,");
            strSql.Append("YGLX=:YGLX,");
            strSql.Append("YGGG=:YGGG,");
            strSql.Append("SJYGWGSD=:SJYGWGSD,");
            strSql.Append("TSSGLX=:TSSGLX,");
            strSql.Append("SYYL=:SYYL,");
            strSql.Append("TGDJG=:TGDJG,");
            strSql.Append("ZLHSD=:ZLHSD,");
            strSql.Append("SKMD=:SKMD,");
            strSql.Append("XW=:XW,");
            strSql.Append("FY=:FY,");
            strSql.Append("WJYMC=:WJYMC,");
            strSql.Append("WJYMD=:WJYMD,");
            strSql.Append("WJYYL=:WJYYL,");
            strSql.Append("SKJD1=:SKJD1,");
            strSql.Append("SKJD2=:SKJD2,");
            strSql.Append("SKHD=:SKHD,");
            strSql.Append("YSK=:YSK,");
            strSql.Append("JSDW=:JSDW,");
            strSql.Append("LRR=:LRR,");
            strSql.Append("SHR=:SHR,");
            strSql.Append("BZ=:BZ,");
            strSql.Append("BKCS=:BKCS,");
            strSql.Append("YL=:YL,");
            strSql.Append("BZ1=:BZ1,");
            strSql.Append("OK=:OK,");
            strSql.Append("TRANS=:TRANS,");
            strSql.Append("CSRQ=:CSRQ,");
            strSql.Append("XH=:XH,");
            strSql.Append("SKDX1=:SKDX1,");
            strSql.Append("YSK1=:YSK1,");
            strSql.Append("SKMD1=:SKMD1,");
            strSql.Append("YGLX1=:YGLX1,");
            strSql.Append("SJYGWGSD1=:SJYGWGSD1,");
            strSql.Append("YGGG1=:YGGG1,");
            strSql.Append("BKGS=:BKGS,");
            strSql.Append("ZJYLX=:ZJYLX,");
            strSql.Append("SKQX2=:SKQX2,");
            strSql.Append("SKHD2=:SKHD2,");
            strSql.Append("QK=:QK,");
            strSql.Append("KB=:KB,");
            strSql.Append("DATAMIGRATION_ID=:DATAMIGRATION_ID,");
            strSql.Append("DCYL=:DCYL,");
            strSql.Append("TSJ=:TSJ,");
            strSql.Append("YCZBSD=:YCZBSD,");
            strSql.Append("XCS=:XCS,");
            strSql.Append("TGTZBXG=:TGTZBXG,");
            strSql.Append("SKBJ=:SKBJ,");
            strSql.Append("SGDW=:SGDW,");
            strSql.Append("cj=:cj");
            strSql.Append(" where ID=:ID ");
            OracleParameter[] parameters = {
                    new OracleParameter(":ID", OracleType.Number,10),
                    new OracleParameter(":LRRQ", OracleType.DateTime),
                    new OracleParameter(":JH", OracleType.VarChar,32),
                    new OracleParameter(":JB", OracleType.VarChar,10),
                    new OracleParameter(":CB", OracleType.VarChar,20),
                    new OracleParameter(":WJFS", OracleType.VarChar,20),
                    new OracleParameter(":SGLX", OracleType.VarChar,20),
                    new OracleParameter(":SKQX", OracleType.VarChar,20),
                    new OracleParameter(":SKDX", OracleType.VarChar,20),
                    new OracleParameter(":CSFS", OracleType.VarChar,20),
                    new OracleParameter(":CYSXH", OracleType.VarChar,200),
                    new OracleParameter(":YGLX", OracleType.VarChar,200),
                    new OracleParameter(":YGGG", OracleType.VarChar,200),
                    new OracleParameter(":SJYGWGSD", OracleType.Number,6),
                    new OracleParameter(":TSSGLX", OracleType.VarChar,100),
                    new OracleParameter(":SYYL", OracleType.VarChar,10),
                    new OracleParameter(":TGDJG", OracleType.Number,5),
                    new OracleParameter(":ZLHSD", OracleType.Number,7),
                    new OracleParameter(":SKMD", OracleType.Number,4),
                    new OracleParameter(":XW", OracleType.Number,5),
                    new OracleParameter(":FY", OracleType.VarChar,14),
                    new OracleParameter(":WJYMC", OracleType.VarChar,20),
                    new OracleParameter(":WJYMD", OracleType.Number,5),
                    new OracleParameter(":WJYYL", OracleType.Number,3),
                    new OracleParameter(":SKJD1", OracleType.Number,7),
                    new OracleParameter(":SKJD2", OracleType.Number,7),
                    new OracleParameter(":SKHD", OracleType.Number,7),
                    new OracleParameter(":YSK", OracleType.Number,4),
                    new OracleParameter(":JSDW", OracleType.VarChar,30),
                    new OracleParameter(":LRR", OracleType.VarChar,20),
                    new OracleParameter(":SHR", OracleType.VarChar,20),
                    new OracleParameter(":BZ", OracleType.NVarChar ,4000),
                    new OracleParameter(":BKCS", OracleType.Number,1),
                    new OracleParameter(":YL", OracleType.Number,4),
                    new OracleParameter(":BZ1", OracleType.VarChar,100),
                    new OracleParameter(":OK", OracleType.Number,1),
                    new OracleParameter(":TRANS", OracleType.Number,1),
                    new OracleParameter(":CSRQ", OracleType.DateTime),
                    new OracleParameter(":XH", OracleType.Number,2),
                    new OracleParameter(":SKDX1", OracleType.VarChar,20),
                    new OracleParameter(":YSK1", OracleType.Number,4),
                    new OracleParameter(":SKMD1", OracleType.Number,4),
                    new OracleParameter(":YGLX1", OracleType.VarChar,200),
                    new OracleParameter(":SJYGWGSD1", OracleType.Number,6),
                    new OracleParameter(":YGGG1", OracleType.VarChar,200),
                    new OracleParameter(":BKGS", OracleType.VarChar,16),
                    new OracleParameter(":ZJYLX", OracleType.VarChar,8),
                    new OracleParameter(":SKQX2", OracleType.VarChar,20),
                    new OracleParameter(":SKHD2", OracleType.Number,7),
                    new OracleParameter(":QK", OracleType.VarChar,20),
                    new OracleParameter(":KB", OracleType.VarChar,10),
                    new OracleParameter(":DATAMIGRATION_ID", OracleType.Number,4),
                    new OracleParameter(":DCYL", OracleType.Number,6),
                    new OracleParameter(":TSJ", OracleType.VarChar,20),
                    new OracleParameter(":YCZBSD", OracleType.Number,8),
                    new OracleParameter(":XCS", OracleType.Number,2),
                    new OracleParameter(":TGTZBXG", OracleType.Number,8),
                    new OracleParameter(":SKBJ", OracleType.VarChar,20),
                    new OracleParameter(":SGDW", OracleType.VarChar,10),
                    new OracleParameter(":cj", OracleType.VarChar,50)
                                           };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.LRRQ;
            parameters[2].Value = model.JH;
            parameters[3].Value = model.JB;
            parameters[4].Value = model.CB;
            parameters[5].Value = model.WJFS;
            parameters[6].Value = model.SGLX;
            parameters[7].Value = model.SKQX;
            parameters[8].Value = model.SKDX;
            parameters[9].Value = model.CSFS;
            parameters[10].Value = model.CYSXH;
            parameters[11].Value = model.YGLX;
            parameters[12].Value = model.YGGG;
            parameters[13].Value = model.SJYGWGSD;
            parameters[14].Value = model.TSSGLX;
            parameters[15].Value = model.SYYL;
            parameters[16].Value = model.TGDJG;
            parameters[17].Value = model.ZLHSD;
            parameters[18].Value = model.SKMD;
            parameters[19].Value = model.XW;
            parameters[20].Value = model.FY;
            parameters[21].Value = model.WJYMC;
            parameters[22].Value = model.WJYMD;
            parameters[23].Value = model.WJYYL;
            parameters[24].Value = model.SKJD1;
            parameters[25].Value = model.SKJD2;
            parameters[26].Value = model.SKHD;
            parameters[27].Value = model.YSK;
            parameters[28].Value = model.JSDW;
            parameters[29].Value = model.LRR;
            parameters[30].Value = model.SHR;
            parameters[31].Value = model.BZ;
            parameters[32].Value = model.BKCS;
            parameters[33].Value = model.YL;
            parameters[34].Value = model.BZ1;
            parameters[35].Value = model.OK;
            parameters[36].Value = model.TRANS;
            parameters[37].Value = model.CSRQ;
            parameters[38].Value = model.XH;
            parameters[39].Value = model.SKDX1;
            parameters[40].Value = model.YSK1;
            parameters[41].Value = model.SKMD1;
            parameters[42].Value = model.YGLX1;
            parameters[43].Value = model.SJYGWGSD1;
            parameters[44].Value = model.YGGG1;
            parameters[45].Value = model.BKGS;
            parameters[46].Value = model.ZJYLX;
            parameters[47].Value = model.SKQX2;
            parameters[48].Value = model.SKHD2;
            parameters[49].Value = model.QK;
            parameters[50].Value = model.KB;
            parameters[51].Value = model.DATAMIGRATION_ID;
            parameters[52].Value = model.DCYL;
            parameters[53].Value = model.TSJ;
            parameters[54].Value = model.YCZBSD;
            parameters[55].Value = model.XCS;
            parameters[56].Value = model.TGTZBXG;
            parameters[57].Value = model.SKBJ;
            parameters[58].Value = model.SGDW;
            parameters[59].Value = model.cj;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(decimal ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from SKGYSJB ");
            strSql.Append(" where ID=:ID ");
            OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,10)			};
            parameters[0].Value = ID;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string IDlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from SKGYSJB ");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOra.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SkgysjbModel GetModel(Int32 ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from SKGYSJB ");//ID,LRRQ,JH,JB,CB,WJFS,SGLX,SKQX,SKDX,CSFS,CYSXH,YGLX,YGGG,SJYGWGSD,TSSGLX,SYYL,TGDJG,ZLHSD,SKMD,XW,FY,WJYMC,WJYMD,WJYYL,SKJD1,SKJD2,SKHD,YSK,JSDW,LRR,SHR,BZ,BKCS,YL,BZ1,OK,TRANS,CSRQ,XH,SKDX1,YSK1,SKMD1,YGLX1,SJYGWGSD1,YGGG1,BKGS,ZJYLX,SKQX2,SKHD2,QK,KB,DATAMIGRATION_ID,DCYL,TSJ,YCZBSD,XCS,TGTZBXG,SKBJ,SGDW
            strSql.Append(" where ID=:ID ");
            OracleParameter[] parameters = {
                    new OracleParameter(":ID", OracleType.Int32)			};
            parameters[0].Value = ID;

            SkgysjbModel model = new SkgysjbModel();
            DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LRRQ"] != null && ds.Tables[0].Rows[0]["LRRQ"].ToString() != "")
                {
                    model.LRRQ = DateTime.Parse(ds.Tables[0].Rows[0]["LRRQ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JH"] != null && ds.Tables[0].Rows[0]["JH"].ToString() != "")
                {
                    model.JH = ds.Tables[0].Rows[0]["JH"].ToString();
                }
                if (ds.Tables[0].Rows[0]["JB"] != null && ds.Tables[0].Rows[0]["JB"].ToString() != "")
                {
                    model.JB = ds.Tables[0].Rows[0]["JB"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CB"] != null && ds.Tables[0].Rows[0]["CB"].ToString() != "")
                {
                    model.CB = ds.Tables[0].Rows[0]["CB"].ToString();
                }
                if (ds.Tables[0].Rows[0]["WJFS"] != null && ds.Tables[0].Rows[0]["WJFS"].ToString() != "")
                {
                    model.WJFS = ds.Tables[0].Rows[0]["WJFS"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SGLX"] != null && ds.Tables[0].Rows[0]["SGLX"].ToString() != "")
                {
                    model.SGLX = ds.Tables[0].Rows[0]["SGLX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SKQX"] != null && ds.Tables[0].Rows[0]["SKQX"].ToString() != "")
                {
                    model.SKQX = ds.Tables[0].Rows[0]["SKQX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SKDX"] != null && ds.Tables[0].Rows[0]["SKDX"].ToString() != "")
                {
                    model.SKDX = ds.Tables[0].Rows[0]["SKDX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CSFS"] != null && ds.Tables[0].Rows[0]["CSFS"].ToString() != "")
                {
                    model.CSFS = ds.Tables[0].Rows[0]["CSFS"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CYSXH"] != null && ds.Tables[0].Rows[0]["CYSXH"].ToString() != "")
                {
                    model.CYSXH = ds.Tables[0].Rows[0]["CYSXH"].ToString();
                }
                if (ds.Tables[0].Rows[0]["YGLX"] != null && ds.Tables[0].Rows[0]["YGLX"].ToString() != "")
                {
                    model.YGLX = ds.Tables[0].Rows[0]["YGLX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["YGGG"] != null && ds.Tables[0].Rows[0]["YGGG"].ToString() != "")
                {
                    model.YGGG = ds.Tables[0].Rows[0]["YGGG"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SJYGWGSD"] != null && ds.Tables[0].Rows[0]["SJYGWGSD"].ToString() != "")
                {
                    model.SJYGWGSD = double.Parse(ds.Tables[0].Rows[0]["SJYGWGSD"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TSSGLX"] != null && ds.Tables[0].Rows[0]["TSSGLX"].ToString() != "")
                {
                    model.TSSGLX = ds.Tables[0].Rows[0]["TSSGLX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SYYL"] != null && ds.Tables[0].Rows[0]["SYYL"].ToString() != "")
                {
                    model.SYYL = ds.Tables[0].Rows[0]["SYYL"].ToString();
                }
                if (ds.Tables[0].Rows[0]["TGDJG"] != null && ds.Tables[0].Rows[0]["TGDJG"].ToString() != "")
                {
                    model.TGDJG = double.Parse(ds.Tables[0].Rows[0]["TGDJG"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ZLHSD"] != null && ds.Tables[0].Rows[0]["ZLHSD"].ToString() != "")
                {
                    model.ZLHSD = double.Parse(ds.Tables[0].Rows[0]["ZLHSD"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SKMD"] != null && ds.Tables[0].Rows[0]["SKMD"].ToString() != "")
                {
                    model.SKMD = int.Parse(ds.Tables[0].Rows[0]["SKMD"].ToString());
                }
                if (ds.Tables[0].Rows[0]["XW"] != null && ds.Tables[0].Rows[0]["XW"].ToString() != "")
                {
                    model.XW = double.Parse(ds.Tables[0].Rows[0]["XW"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FY"] != null && ds.Tables[0].Rows[0]["FY"].ToString() != "")
                {
                    model.FY = ds.Tables[0].Rows[0]["FY"].ToString();
                }
                if (ds.Tables[0].Rows[0]["WJYMC"] != null && ds.Tables[0].Rows[0]["WJYMC"].ToString() != "")
                {
                    model.WJYMC = ds.Tables[0].Rows[0]["WJYMC"].ToString();
                }
                if (ds.Tables[0].Rows[0]["WJYMD"] != null && ds.Tables[0].Rows[0]["WJYMD"].ToString() != "")
                {
                    model.WJYMD =double.Parse(ds.Tables[0].Rows[0]["WJYMD"].ToString());
                }
                if (ds.Tables[0].Rows[0]["WJYYL"] != null && ds.Tables[0].Rows[0]["WJYYL"].ToString() != "")
                {
                    model.WJYYL = int.Parse(ds.Tables[0].Rows[0]["WJYYL"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SKJD1"] != null && ds.Tables[0].Rows[0]["SKJD1"].ToString() != "")
                {
                    model.SKJD1 = double.Parse(ds.Tables[0].Rows[0]["SKJD1"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SKJD2"] != null && ds.Tables[0].Rows[0]["SKJD2"].ToString() != "")
                {
                    model.SKJD2 = double.Parse(ds.Tables[0].Rows[0]["SKJD2"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SKHD"] != null && ds.Tables[0].Rows[0]["SKHD"].ToString() != "")
                {
                    model.SKHD = double.Parse(ds.Tables[0].Rows[0]["SKHD"].ToString());
                }
                if (ds.Tables[0].Rows[0]["YSK"] != null && ds.Tables[0].Rows[0]["YSK"].ToString() != "")
                {
                    model.YSK = int.Parse(ds.Tables[0].Rows[0]["YSK"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JSDW"] != null && ds.Tables[0].Rows[0]["JSDW"].ToString() != "")
                {
                    model.JSDW = ds.Tables[0].Rows[0]["JSDW"].ToString();
                }
                if (ds.Tables[0].Rows[0]["LRR"] != null && ds.Tables[0].Rows[0]["LRR"].ToString() != "")
                {
                    model.LRR = ds.Tables[0].Rows[0]["LRR"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SHR"] != null && ds.Tables[0].Rows[0]["SHR"].ToString() != "")
                {
                    model.SHR = ds.Tables[0].Rows[0]["SHR"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BZ"] != null && ds.Tables[0].Rows[0]["BZ"].ToString() != "")
                {
                    model.BZ = ds.Tables[0].Rows[0]["BZ"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BKCS"] != null && ds.Tables[0].Rows[0]["BKCS"].ToString() != "")
                {
                    model.BKCS = int.Parse(ds.Tables[0].Rows[0]["BKCS"].ToString());
                }
                if (ds.Tables[0].Rows[0]["YL"] != null && ds.Tables[0].Rows[0]["YL"].ToString() != "")
                {
                    model.YL = int.Parse(ds.Tables[0].Rows[0]["YL"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BZ1"] != null && ds.Tables[0].Rows[0]["BZ1"].ToString() != "")
                {
                    model.BZ1 = ds.Tables[0].Rows[0]["BZ1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["OK"] != null && ds.Tables[0].Rows[0]["OK"].ToString() != "")
                {
                    model.OK = int.Parse(ds.Tables[0].Rows[0]["OK"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TRANS"] != null && ds.Tables[0].Rows[0]["TRANS"].ToString() != "")
                {
                    model.TRANS = int.Parse(ds.Tables[0].Rows[0]["TRANS"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CSRQ"] != null && ds.Tables[0].Rows[0]["CSRQ"].ToString() != "")
                {
                    model.CSRQ = DateTime.Parse(ds.Tables[0].Rows[0]["CSRQ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["XH"] != null && ds.Tables[0].Rows[0]["XH"].ToString() != "")
                {
                    model.XH = int.Parse(ds.Tables[0].Rows[0]["XH"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SKDX1"] != null && ds.Tables[0].Rows[0]["SKDX1"].ToString() != "")
                {
                    model.SKDX1 = ds.Tables[0].Rows[0]["SKDX1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["YSK1"] != null && ds.Tables[0].Rows[0]["YSK1"].ToString() != "")
                {
                    model.YSK1 = int.Parse(ds.Tables[0].Rows[0]["YSK1"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SKMD1"] != null && ds.Tables[0].Rows[0]["SKMD1"].ToString() != "")
                {
                    model.SKMD1 = int.Parse(ds.Tables[0].Rows[0]["SKMD1"].ToString());
                }
                if (ds.Tables[0].Rows[0]["YGLX1"] != null && ds.Tables[0].Rows[0]["YGLX1"].ToString() != "")
                {
                    model.YGLX1 = ds.Tables[0].Rows[0]["YGLX1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SJYGWGSD1"] != null && ds.Tables[0].Rows[0]["SJYGWGSD1"].ToString() != "")
                {
                    model.SJYGWGSD1 = double.Parse(ds.Tables[0].Rows[0]["SJYGWGSD1"].ToString());
                }
                if (ds.Tables[0].Rows[0]["YGGG1"] != null && ds.Tables[0].Rows[0]["YGGG1"].ToString() != "")
                {
                    model.YGGG1 = ds.Tables[0].Rows[0]["YGGG1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BKGS"] != null && ds.Tables[0].Rows[0]["BKGS"].ToString() != "")
                {
                    model.BKGS = ds.Tables[0].Rows[0]["BKGS"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ZJYLX"] != null && ds.Tables[0].Rows[0]["ZJYLX"].ToString() != "")
                {
                    model.ZJYLX = ds.Tables[0].Rows[0]["ZJYLX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SKQX2"] != null && ds.Tables[0].Rows[0]["SKQX2"].ToString() != "")
                {
                    model.SKQX2 = ds.Tables[0].Rows[0]["SKQX2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SKHD2"] != null && ds.Tables[0].Rows[0]["SKHD2"].ToString() != "")
                {
                    model.SKHD2 = double.Parse(ds.Tables[0].Rows[0]["SKHD2"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QK"] != null && ds.Tables[0].Rows[0]["QK"].ToString() != "")
                {
                    model.QK = ds.Tables[0].Rows[0]["QK"].ToString();
                }
                if (ds.Tables[0].Rows[0]["KB"] != null && ds.Tables[0].Rows[0]["KB"].ToString() != "")
                {
                    model.KB = ds.Tables[0].Rows[0]["KB"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DATAMIGRATION_ID"] != null && ds.Tables[0].Rows[0]["DATAMIGRATION_ID"].ToString() != "")
                {
                    model.DATAMIGRATION_ID = int.Parse(ds.Tables[0].Rows[0]["DATAMIGRATION_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DCYL"] != null && ds.Tables[0].Rows[0]["DCYL"].ToString() != "")
                {
                    model.DCYL = double.Parse(ds.Tables[0].Rows[0]["DCYL"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TSJ"] != null && ds.Tables[0].Rows[0]["TSJ"].ToString() != "")
                {
                    model.TSJ = ds.Tables[0].Rows[0]["TSJ"].ToString();
                }
                if (ds.Tables[0].Rows[0]["YCZBSD"] != null && ds.Tables[0].Rows[0]["YCZBSD"].ToString() != "")
                {
                    model.YCZBSD = double.Parse(ds.Tables[0].Rows[0]["YCZBSD"].ToString());
                }
                if (ds.Tables[0].Rows[0]["XCS"] != null && ds.Tables[0].Rows[0]["XCS"].ToString() != "")
                {
                    model.XCS = int.Parse(ds.Tables[0].Rows[0]["XCS"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TGTZBXG"] != null && ds.Tables[0].Rows[0]["TGTZBXG"].ToString() != "")
                {
                    model.TGTZBXG = double.Parse(ds.Tables[0].Rows[0]["TGTZBXG"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SKBJ"] != null && ds.Tables[0].Rows[0]["SKBJ"].ToString() != "")
                {
                    model.SKBJ = ds.Tables[0].Rows[0]["SKBJ"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SGDW"] != null && ds.Tables[0].Rows[0]["SGDW"].ToString() != "")
                {
                    model.SGDW = ds.Tables[0].Rows[0]["SGDW"].ToString();
                }
                if (ds.Tables[0].Rows[0]["shrq"] != null && ds.Tables[0].Rows[0]["shrq"].ToString() != "")
                {
                    model.SHRQ =Convert.ToDateTime( ds.Tables[0].Rows[0]["shrq"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SHWTGYY"] != null && ds.Tables[0].Rows[0]["SHWTGYY"].ToString() != "")
                {
                    model.SHWTGYY = ds.Tables[0].Rows[0]["SHWTGYY"].ToString();
                }

                if (ds.Tables[0].Rows[0]["cj"] != null)
                {
                    model.cj = ds.Tables[0].Rows[0]["cj"].ToString();
                }

                //新添加
                SetValue(model);
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,LRRQ,JH,JB,CB,WJFS,SGLX,SKQX,SKDX,CSFS,CYSXH,YGLX,YGGG,SJYGWGSD,TSSGLX,SYYL,TGDJG,ZLHSD,SKMD,XW,FY,WJYMC,WJYMD,WJYYL,SKJD1,SKJD2,SKHD,YSK,JSDW,LRR,SHR,BZ,BKCS,YL,BZ1,OK,TRANS,CSRQ,XH,SKDX1,YSK1,SKMD1,YGLX1,SJYGWGSD1,YGGG1,BKGS,ZJYLX,SKQX2,SKHD2,QK,KB,DATAMIGRATION_ID,DCYL,TSJ,YCZBSD,XCS,TGTZBXG,SKBJ,SGDW ");
            strSql.Append(" FROM SKGYSJB ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperOra.Query(strSql.ToString());
        }

        

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM SKGYSJB ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperOra.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.ID desc");
            }
            strSql.Append(")AS Row1, T.*  from SKGYSJB T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row1 between {0} and {1}", startIndex, endIndex);
            return DbHelperOra.Query(strSql.ToString());
        }


        public DataTable getSKGYSJBDataBySQL(string userCode, string wellCode, int pageSize, int pageIndex, out int recordCount)
        {
            string firstSql = @"SELECT A.ID,
                                   A.JH     ,
                                   A.JB     ,
                                   A.CSFS  ,
                                   A.SGLX  ,
                                   A.WJYMD  ,
                                   A.WJYMC  ,
                                   A.YGGG,A.SKQX, A.SKDX, A.SHR, A.LRR,
                                   A.ZLHSD, B.SH
                              FROM SKGYSJB A inner join  ZYSGSJ B on  A.ID = B.ID 
                              where 1=1 ";
            if (!string.IsNullOrWhiteSpace(wellCode))
            {
                firstSql += string.Format("  and A.jh like '%{0}%' ", wellCode);
            }

            firstSql += " order by A.JH DESC";
            return DbHelperOra.ExecutePageQuery(firstSql, pageSize, pageIndex, out recordCount);
        }

        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            OracleParameter[] parameters = {
                    new OracleParameter(":tblName", OracleType.VarChar, 255),
                    new OracleParameter(":fldName", OracleType.VarChar, 255),
                    new OracleParameter(":PageSize", OracleType.Number),
                    new OracleParameter(":PageIndex", OracleType.Number),
                    new OracleParameter(":IsReCount", OracleType.Clob),
                    new OracleParameter(":OrderType", OracleType.Clob),
                    new OracleParameter(":strWhere", OracleType.VarChar,1000),
                    };
            parameters[0].Value = "SKGYSJB";
            parameters[1].Value = "ID";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion  Method

        #region 新添加
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere,  int PageIndex, int pageSize)
        {
            int iStartIndex = (PageIndex - 1) * pageSize;
            int iEndIndex = PageIndex * pageSize;

            return GetListByPage( strWhere, "",iStartIndex,iEndIndex);
        }

        /// <summary>
        /// 初始化数据
        /// </summary>
        /// <param name="objSKGYSJB"></param>
        public void InitSKGYSJB(SkgysjbModel objSKGYSJB)
        {
            #region 
            objSKGYSJB.BKCS = 0;
            objSKGYSJB.BKGS = "";
            objSKGYSJB.BZ = "";
            objSKGYSJB.BZ1 = "";
            objSKGYSJB.CB = "";
            objSKGYSJB.CSFS = "";
            objSKGYSJB.CSRQ = Convert.ToDateTime("1900-1-1");
            objSKGYSJB.CYSXH = "";
            //objSKGYSJB.DATAMIGRATION_ID = 0;
            objSKGYSJB.DCYL = 0;
            objSKGYSJB.FY = "";
            objSKGYSJB.ID = 0;
            objSKGYSJB.JB = "";
            objSKGYSJB.JH = "";
            objSKGYSJB.JSDW = "";
            objSKGYSJB.KB = "";
            objSKGYSJB.LRR = "";
            objSKGYSJB.LRRQ = Convert.ToDateTime("1900-1-1");
            objSKGYSJB.OK = 0;
            objSKGYSJB.QK = "";
            objSKGYSJB.SGDW = "";
            objSKGYSJB.SGLX = "";
            objSKGYSJB.SHR = "";
            objSKGYSJB.SJYGWGSD = 0;
            objSKGYSJB.SJYGWGSD1 = 0;
            objSKGYSJB.SKBJ = "";
            objSKGYSJB.SKDX = "";
            objSKGYSJB.SKDX1 = "";
            objSKGYSJB.SKHD = 0;
            objSKGYSJB.SKHD2 = 0;
            objSKGYSJB.SKJD1 = 0;
            objSKGYSJB.SKJD2 = 0;
            objSKGYSJB.SKMD = 0;
            objSKGYSJB.SKMD1 = 0;
            objSKGYSJB.SKQX = "";
            objSKGYSJB.SKQX2 = "";
            objSKGYSJB.SYYL = "";
            objSKGYSJB.TGDJG = 0;
            objSKGYSJB.TGTZBXG = 0;
            objSKGYSJB.TRANS = 0;
            objSKGYSJB.TSJ = "";
            objSKGYSJB.TSSGLX = "";
            objSKGYSJB.WJFS = "";
            objSKGYSJB.WJYMC = "";
            objSKGYSJB.WJYMD=0;
            objSKGYSJB.WJYYL=0;
            objSKGYSJB.XCS = 0;
            objSKGYSJB.XH = 0;
            objSKGYSJB.XW = 0;
            objSKGYSJB.YCZBSD = 0;
            objSKGYSJB.YGGG = "";
            objSKGYSJB.YGGG1 = "";
            objSKGYSJB.YGLX = "";
            objSKGYSJB.YGLX1 = "";
            objSKGYSJB.YL = 0;
            objSKGYSJB.YSK = 0;
            objSKGYSJB.YSK1 = 0;
            objSKGYSJB.ZJYLX = "";
            objSKGYSJB.ZLHSD = 0;
            objSKGYSJB.cj = "";

            #endregion
        }

        /// <summary>
        /// 获得下一个ID值
        /// </summary>
        /// <returns></returns>
        public int GetNextID()
        {
            #region 
            return DbHelperOra.GetMaxID("ID", "SKGYSJB");
            #endregion
        }
        /// <summary>
        /// 获得下一个ID
        /// </summary>
        /// <param name="FieldName">字段名</param>
        /// <returns></returns>
        public int GetNextID(string FieldName)
        {
            #region
            return DbHelperOra.GetMaxID(FieldName, "SKGYSJB");
            #endregion
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="objSKGYSJB"></param>
        public void SetValue(SkgysjbModel objSKGYSJB)
        {
            #region 
            objSKGYSJB.BKCS = SetNotNull(objSKGYSJB.BKCS);
            objSKGYSJB.BKGS = SetNotNull(objSKGYSJB.BKGS);
            if (objSKGYSJB.BZ==null)
            {
                objSKGYSJB.BZ = " ";
            }
            objSKGYSJB.BZ1 = SetNotNull(objSKGYSJB.BZ1);
            objSKGYSJB.CB = SetNotNull(objSKGYSJB.CB);
            objSKGYSJB.CSFS = SetNotNull(objSKGYSJB.CSFS);
            //objSKGYSJB.CSRQ = Convert.ToDateTime("1900-1-1");
            objSKGYSJB.CYSXH = SetNotNull(objSKGYSJB.CYSXH);
            //objSKGYSJB.DATAMIGRATION_ID = SetNotNull(objSKGYSJB.BKGS);
            objSKGYSJB.DCYL = SetNotNull(objSKGYSJB.DCYL);
            objSKGYSJB.FY = SetNotNull(objSKGYSJB.FY);
            //objSKGYSJB.ID = SetNotNull(objSKGYSJB.BKGS);
            objSKGYSJB.JB = SetNotNull(objSKGYSJB.JB);
            //objSKGYSJB.JH = SetNotNull(objSKGYSJB.BKGS);
            objSKGYSJB.JSDW = SetNotNull(objSKGYSJB.JSDW);
            objSKGYSJB.KB = SetNotNull(objSKGYSJB.KB);
            objSKGYSJB.LRR = SetNotNull(objSKGYSJB.LRR);
            //objSKGYSJB.LRRQ = Convert.ToDateTime("1900-1-1");
            objSKGYSJB.OK = SetNotNull(objSKGYSJB.OK);
            objSKGYSJB.QK = SetNotNull(objSKGYSJB.QK);
            objSKGYSJB.SGDW = SetNotNull(objSKGYSJB.SGDW);
            objSKGYSJB.SGLX = SetNotNull(objSKGYSJB.SGLX);
            objSKGYSJB.SHR = SetNotNull(objSKGYSJB.SHR);
            objSKGYSJB.SJYGWGSD = SetNotNull(objSKGYSJB.SJYGWGSD);
            objSKGYSJB.SJYGWGSD1 = SetNotNull(objSKGYSJB.SJYGWGSD1);
            objSKGYSJB.SKBJ = SetNotNull(objSKGYSJB.SKBJ);
            objSKGYSJB.SKDX = SetNotNull(objSKGYSJB.SKDX);
            objSKGYSJB.SKDX1 = SetNotNull(objSKGYSJB.SKDX1);
            objSKGYSJB.SKHD = SetNotNull(objSKGYSJB.SKHD);
            objSKGYSJB.SKHD2 = SetNotNull(objSKGYSJB.SKHD2);
            objSKGYSJB.SKJD1 = SetNotNull(objSKGYSJB.SKJD1);
            objSKGYSJB.SKJD2 = SetNotNull(objSKGYSJB.SKJD2);
            objSKGYSJB.SKMD = SetNotNull(objSKGYSJB.SKMD);
            objSKGYSJB.SKMD1 = SetNotNull(objSKGYSJB.SKMD1);
            objSKGYSJB.SKQX = SetNotNull(objSKGYSJB.SKQX);
            objSKGYSJB.SKQX2 = SetNotNull(objSKGYSJB.SKQX2);
            objSKGYSJB.SYYL = SetNotNull(objSKGYSJB.SYYL);
            objSKGYSJB.TGDJG = SetNotNull(objSKGYSJB.TGDJG);
            objSKGYSJB.TGTZBXG = SetNotNull(objSKGYSJB.TGTZBXG);
            objSKGYSJB.TRANS = SetNotNull(objSKGYSJB.TRANS);
            objSKGYSJB.TSJ = SetNotNull(objSKGYSJB.TSJ);
            objSKGYSJB.TSSGLX = SetNotNull(objSKGYSJB.TSSGLX);
            objSKGYSJB.WJFS = SetNotNull(objSKGYSJB.WJFS);
            objSKGYSJB.WJYMC = SetNotNull(objSKGYSJB.WJYMC);
            objSKGYSJB.WJYMD = SetNotNull(objSKGYSJB.WJYMD);
            objSKGYSJB.WJYYL = SetNotNull(objSKGYSJB.WJYYL);
            objSKGYSJB.XCS = SetNotNull(objSKGYSJB.XCS);
            objSKGYSJB.XH = SetNotNull(objSKGYSJB.XH);
            objSKGYSJB.XW = SetNotNull(objSKGYSJB.XW);
            objSKGYSJB.YCZBSD = SetNotNull(objSKGYSJB.YCZBSD);
            objSKGYSJB.YGGG = SetNotNull(objSKGYSJB.YGGG);
            objSKGYSJB.YGGG1 = SetNotNull(objSKGYSJB.YGGG1);
            objSKGYSJB.YGLX = SetNotNull(objSKGYSJB.YGLX);
            objSKGYSJB.YGLX1 = SetNotNull(objSKGYSJB.YGLX1);
            objSKGYSJB.YL = SetNotNull(objSKGYSJB.YL);
            objSKGYSJB.YSK = SetNotNull(objSKGYSJB.YSK);
            objSKGYSJB.YSK1 = SetNotNull(objSKGYSJB.YSK1);
            objSKGYSJB.ZJYLX = SetNotNull(objSKGYSJB.ZJYLX);
            objSKGYSJB.ZLHSD = SetNotNull(objSKGYSJB.ZLHSD);
            objSKGYSJB.SHWTGYY = SetNotNull(objSKGYSJB.SHWTGYY);

            #endregion
        }
        /// <summary>
        /// 判断当前字符变量是否为空，如果为空则返回“”，否则返回原字符
        /// </summary>
        /// <param name="NullObj"></param>
        /// <returns></returns>
        public string SetNotNull(string NullObj)
        {
            if (NullObj == null)
            {
                return "";
            }
            return NullObj;
        }

        public int SetNotNull(int NullObj)
        {
            return NullObj;
        }

        public double SetNotNull(double NullObj)
        {
            return NullObj;
        }


        /// <summary>
        /// 删除相关表记录
        /// </summary>
        /// <param name="IDlist">ID字符串</param>
        /// <returns></returns>
        public bool DeleteListAll(string IDlist)
        {
            #region 
            ArrayList alSQL = new ArrayList();

            string strSQL="delete from SKGYSJB where ID in (" + IDlist + ")  ";
            alSQL.Add(strSQL);
            strSQL = "delete from jwkc where ID in (" + IDlist + ")  ";
            alSQL.Add(strSQL);
            strSQL = "delete from zysgsj where ID in (" + IDlist + ")  ";
            alSQL.Add(strSQL);
            strSQL = "delete from skxcsjb where ID in (" + IDlist + ")  ";
            alSQL.Add(strSQL);
            strSQL = "delete from dzyck where ID in (" + IDlist + ")  ";
            alSQL.Add(strSQL);
            strSQL = "delete from eczxbg1 where ID in (" + IDlist + ")  ";
            alSQL.Add(strSQL);
            strSQL = "delete from eczxbg2 where ID in (" + IDlist + ")  ";
            alSQL.Add(strSQL);
            strSQL = "delete from gnqtyl where ID in (" + IDlist + ")  ";
            alSQL.Add(strSQL);
            DbHelperOra.ExecuteSqlTran(alSQL);
            return true;

            #endregion
        }


        /// <summary>
        /// 执行事务
        /// </summary>
        /// <param name="alSQL"></param>
        public void ExecuteSqlTran(ArrayList alSQL)
        {
            DbHelperOra.ExecuteSqlTran(alSQL);
        }

        /// <summary>
        /// 更新测试日期
        /// </summary>
        /// <param name="strID">ID字符串，如：2,4,5</param>
        public int UpdateCSRQ(string strID)
        {
            string strSQL = "UPDATE skgysjb SET csrq=to_date('" + DateTime.Now.ToShortDateString() + "','yyyy-mm-dd'),trans=1 WHERE id in(" + strID + ")";
            return  DbHelperOra.ExecuteSql(strSQL);
        }
        /// <summary>
        /// 更新审核状态
        /// </summary>
        /// <param name="strID">ID字符串，如：2,4,5</param>
        public int UpdateSHZT(string strSQL) 
        {
            //string strSQL = "UPDATE skgysjb SET csrq=to_date('" + DateTime.Now.ToShortDateString() + "','yyyy-mm-dd'),trans=1 WHERE id in(" + strID + ")";
            return DbHelperOra.ExecuteSql(strSQL);
        }

        /// <summary>
        /// 更新施工后数据设计状态
        /// </summary>
        /// <param name="strID">ID字符串，如：2,4,5</param>
        public int UpdateSJZT(string ID)
        {
            string strSQL = "update zysghsj set lrf = 1 ,sjwf=1 where id='"+ID+"'";
            return DbHelperOra.ExecuteSql(strSQL);
        }

        /// <summary>
        /// 更新射孔数据变更接收状态
        /// </summary>
        /// <param name="strID">ID字符串，如：2,4,5</param>
        public int UpdateSKOK(string ID)
        {
            string strSQL = "update mon_skgysjb set ok = 1 where id='" + ID + "'";
            return DbHelperOra.ExecuteSql(strSQL);
        }
        /// <summary>
        /// 更新作业施工数据变更接收状态
        /// </summary>
        /// <param name="strID">ID字符串，如：2,4,5</param>
        public int UpdateZYOK(string ID)
        {
            string strSQL = "update mon_zysgsj set ok = 1 where id='" + ID + "'";
            return DbHelperOra.ExecuteSql(strSQL);
        }


        /// <summary>
        /// 获得结果记录数
        /// </summary>
        /// <param name="strSQL">统计sql</param>
        /// <returns></returns>
        public int GetResultNum(string strSQL)
        {
            object obj= DbHelperOra.GetSingle(strSQL);
            if(obj !=null )
            {
                return Convert.ToInt32(obj);
            }
            else
            {
                return 0;
            }
        }


        /// <summary>
        /// 通过审核
        /// </summary>
        /// <param name="IDlist">ID字符串</param>
        /// <returns></returns>
        public bool TGSH(string IDlist,string shr)
        {
            #region
            ArrayList alSQL = new ArrayList();

            string strSQL = "update SKGYSJB set shzt=1,SHRQ=to_date('" + DateTime.Now.ToShortDateString() + "','yyyy-mm-dd'),shr='"+shr+"' where ID in (" + IDlist + ")  ";
            int iNum= DbHelperOra.ExecuteSql(strSQL);
            if (iNum > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
            

            #endregion
        }

        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="ID">ID号</param>
        /// <param name="OK">审核是否通过</param>
        /// <param name="SHWTGYY">未通过原因</param>
        /// <returns></returns>
        public bool SH(int ID, int OK, string SHWTGYY,string SHR)
        {
            #region 
            string strSQL = "update SKGYSJB set shzt="+OK.ToString()+",SHRQ=to_date('" + DateTime.Now.ToString() + "','yyyy-mm-dd HH24:MI:SS'),SHWTGYY='"+SHWTGYY+"',shr='"+SHR+"' where ID =" + ID.ToString();
            int iNum = DbHelperOra.ExecuteSql(strSQL);
            if (iNum > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
            #endregion
        }

        /// <summary>
        /// 获得查询结果
        /// </summary>
        /// <param name="strSQL">查询 sql</param>
        /// <returns></returns>
        public DataTable GetData(string strSQL)
        {
            return DbHelperOra.Query(strSQL).Tables[0];
        }
        #endregion

        #region 射孔项目添加

        public DataTable QuerySchemeDesignWell(string id, int pageSize, int pageIndex, out int recordCount)
        {
            string firstSql = @"SELECT A.ID,
                                   A.JH     ,
                                   A.JB     ,
                                   A.SKJD1  ,
                                   A.SKJD2  ,
                                   A.WJYMD  ,
                                   A.WJYMC  ,
                                   A.ZLHSD, B.SH
                              FROM SKGYSJB A inner join  ZYSGSJ B on  A.ID = B.ID where 1=1 ";
            if (!string.IsNullOrWhiteSpace(id))
            {
                firstSql += string.Format("  and A.ID={0} ", id);
            }

            firstSql += " order by A.JH DESC";
            return DbHelperOra.ExecutePageQuery(firstSql, pageSize, pageIndex, out recordCount);
        }

        public DataTable QuerySchemeDesignWellByWellCode(string userCode,string wellCode,string strDateSpan, int pageSize, int pageIndex, out int recordCount)
        {



//            string firstSql = @"SELECT A.ID,
//                                   A.JH     ,
//                                   A.JB     ,
//                                   A.CSFS  ,
//                                   A.SGLX  ,
//                                   A.WJYMD  ,
//                                   A.WJYMC  ,
//                                   A.YGGG,A.SKQX, A.SKDX, A.SHR, A.LRR,
//                                   A.ZLHSD, B.SH,case C.SHENHE when -1 then '退回' else '' end as zhuangtai
//                              FROM SKGYSJB A inner join  ZYSGSJ B on  A.ID = B.ID  left join tb_fa C ON  A.ID =C.jing_ID
//                              where 1=1 and(select bum_mc from tb_sys_department 
//                              where (select bum_id from tb_sys_user where use_code = '" + userCode
//                 + "'  ) = tb_sys_department.bum_id  ) = a.csfs and a.id not in (select jing_id from tb_fa where dbms_lob.getlength(word_doc)>0 and shenhe!=-1)";/

            string firstSql = @"SELECT A.ID,
                                   A.JH     ,
                                   A.JB     ,
                                   A.CSFS  ,
                                   A.SGLX  ,
                                   A.WJYMD  ,
                                   A.WJYMC  ,
                                   A.YGGG,A.SKQX, A.SKDX, A.SHR, A.LRR,
                                   A.ZLHSD, case C.SHENHE when -1 then '退回' else '' end as zhuangtai
                              FROM SKGYSJB A  left join tb_fa C ON  A.ID =C.jing_ID
                              where 1=1 and(select bum_mc from tb_sys_department 
                              where (select bum_id from tb_sys_user where use_code = '" + userCode
                 + "'  ) = tb_sys_department.bum_id  ) = a.csfs and a.id not in (select jing_id from tb_fa where dbms_lob.getlength(word_doc)>0 and shenhe!=-1)";//select jing_id from tb_fa where sjr_code='" + userCode + "' and shenhe!=-1
            if (!string.IsNullOrWhiteSpace(wellCode))
            {
                firstSql += string.Format("  and A.jh like '%{0}%' ", wellCode);
            }
            if (string.IsNullOrWhiteSpace(strDateSpan))
            {
                strDateSpan = "2";
            }
            firstSql += string.Format("  and A.lrrq > sysdate- {0} ", strDateSpan);

            firstSql += " order by A.lrrq DESC";
            return DbHelperOra.ExecutePageQuery(firstSql, pageSize, pageIndex, out recordCount);
        }

        public bool UpdateSchemeDesignWell(SkgysjbModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update SKGYSJB set ");

            strSql.Append("JB=:JB,");
            strSql.Append("SKQX=:SKQX,");
            strSql.Append("SKDX=:SKDX,");
            strSql.Append("YGGG=:YGGG,");

            strSql.Append("WJYMC=:WJYMC,");
            strSql.Append("WJYMD=:WJYMD,");

            strSql.Append("SKJD1=:SKJD1,");
            strSql.Append("SKJD2=:SKJD2");

            strSql.Append(" where ID=:ID ");
            OracleParameter[] parameters = {
                    new OracleParameter(":ID", OracleType.Number,10),
                    new OracleParameter(":JB", OracleType.VarChar,10),
                    new OracleParameter(":SKQX", OracleType.VarChar,20),
                    new OracleParameter(":SKDX", OracleType.VarChar,20),
                    
                    new OracleParameter(":YGGG", OracleType.VarChar,200),
                    
                    new OracleParameter(":WJYMC", OracleType.VarChar,20),
                    new OracleParameter(":WJYMD", OracleType.Number,5),
                    
                    new OracleParameter(":SKJD1", OracleType.Number,7),
                    new OracleParameter(":SKJD2", OracleType.Number,7)
                                           };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.JB;
            parameters[2].Value = model.SKQX;
            parameters[3].Value = model.SKDX;
            parameters[4].Value = model.YGGG;
            parameters[5].Value = model.WJYMC;
            parameters[6].Value = model.WJYMD;
            parameters[7].Value = model.SKJD1;
            parameters[8].Value = model.SKJD2;
            

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);

            strSql.Clear();

            strSql.AppendLine("update zysgsj ");
            strSql.AppendLine("set qcyzsd = :qcyzsd ");
            strSql.AppendLine("where id = :id");

            OracleParameter[] parameterArr = new OracleParameter[] {
                new OracleParameter(":id", OracleType.Number,10),
                new OracleParameter(":qcyzsd", OracleType.Number, 7)
            };

            parameterArr[0].Value = model.ID;
            parameterArr[1].Value = model.YCZBSD;

            int rs = DbHelperOra.ExecuteSql(strSql.ToString(), parameterArr);

            if (rows > 0 && rs > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public DataTable QueryWellSchemeDesignByUser(string jh, string sjr, string beginDate, string endDate, int pageSize, int pageIndex, out int recordCount)
        {
            string firstSql = @"SELECT A.ID, A.JH, A.JB, A.SKJD1, A.SKJD2, A.WJYMD, A.WJYMC, b.sjr, b.sjrq, c.tmp_mc,B.ID FA_ID
                                 FROM SKGYSJB A
                                INNER JOIN tb_fa B
                                   ON A.ID = b.jing_id
                                   INNER JOIN tb_template_menu c ON b.tmp_id = c.tmp_id
                                WHERE 1 = 1 and b.shenhe>=2 ";
            if (!string.IsNullOrWhiteSpace(sjr))
            {
                firstSql += string.Format("  and B.SJR='%{0}%' ", sjr);
            }
            if (!string.IsNullOrWhiteSpace(jh))
            {
                firstSql += string.Format("  and A.JH like '%{0}%'", jh);
            }
            firstSql += string.Format("  and B.SJRQ between to_date('{0}','yyyy-mm-dd') and to_date('{1}','yyyy-mm-dd') ", beginDate, endDate);

            firstSql += " order by B.SJRQ DESC";
            return DbHelperOra.ExecutePageQuery(firstSql, pageSize, pageIndex, out recordCount);
        }

        #endregion
    }
}

